<?php
class UserAuth_Core {

	public function login($role,$username,$password){
		$session = Session::instance();
		if($role=="login"){
			$user = ORM::factory($username, $password);
			if($user){
				$session->set("user", $user);
				$session->set("role", $user->role);
			}else{
				$session->set("user", null);
				$session->set("role", null);
			}
		}else if($role=="admin"){
			$user = ORM::factory($username, $password);
			if($user){
				$session->set("admin", $user);
				$session->set("role", $user->role);
			}else{
				$session->set("admin", null);
				$session->set("role", null);
			}
		}
	}

	public  function logout($role,$session){
		//$session = Session::instance();
		if($role=='user'){
			$session->set("user", null);
		}else if($role=="admin"){
			$session->set("user", null);
		}
	}
	
	public  function get($role){
		if($role=='user'){
			return Session::instance()->get("user");
		}else if($role=='admin'){
			return Session::instance()->get("admin");
		}
	}
	
}

?>